package madixin.t58;

import java.util.StringTokenizer;

class Solution {
    public int lengthOfLastWord(String s) {
        if (s == null || s.length() == 0) {
            return 0;
        }
        if (s.trim().length() == 0) {
            return 0;
        }
//        StringTokenizer token = new StringTokenizer(s, " ");
//        while (token.hasMoreTokens()){
//            System.out.println();
//        }
        String[] words = s.split(" ");
        if (words.length == 0) {
            return s.length();
        }
        return words[words.length - 1].trim().length();
    }

    public static void main(String[] args) {
        Solution s = new Solution();
        System.out.println(s.lengthOfLastWord("a "));
    }
}